home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 14.3 KB | 493 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWFileSp.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #ifndef FWFILESP_H
- #include "FWFileSp.h"
- #endif
-
- #ifndef FWFILESY_H
- #include "FWFileSy.h"
- #endif
-
- #ifndef FWEXCLIB_H
- #include "FWExcLib.h"
- #endif
-
- #ifndef FWBNDSTR_H
- #include "FWBndStr.h"
- #endif
-
- #if defined(FW_BUILD_MAC) && !defined(__ERRORS__)
- #include <Errors.h>
- #endif
-
- #if defined(FW_BUILD_MAC) && !defined(__FINDER__)
- #include <Finder.h>
- #endif
-
- #if defined(FW_BUILD_WIN) && !defined(__IO_H)
- #include <io.h>
- #endif
-
-
- #ifdef FW_BUILD_MAC
- #pragma segment FW_PFileSpecification
- #endif
-
- //========================================================================================
- // Template instantiations
- //========================================================================================
-
- #include "FWSOMPtr.tpp"
-
- FW_DEFINE_AUTO_TEMPLATE(FW_TSOMPtr, FW_OFileSpecification)
- FW_DEFINE_AUTO_TEMPLATE(FW_TSOMPtr, FW_ODirectorySpecification)
-
- #if FW_USE_TEMPLATE_PRAGMAS
- #pragma template_access public
- #pragma template FW_TSOMPtr<FW_OFileSpecification>
- #pragma template FW_TSOMPtr<FW_ODirectorySpecification>
- #endif
-
- #if FW_ANSI_TEMPLATE_INTANSTIATION
- template class FW_TSOMPtr<FW_OFileSpecification>;
- template class FW_TSOMPtr<FW_ODirectorySpecification>;
- #endif
-
- //========================================================================================
- // CLASS FW_PFileSpecification
- //========================================================================================
-
- FW_DEFINE_AUTO(FW_PFileSpecification)
-
- //----------------------------------------------------------------------------------------
- // FW_PFileSpecification::FW_PFileSpecification
- //
- // Create a file specification from a directory and a file name.
- //----------------------------------------------------------------------------------------
-
- FW_PFileSpecification::FW_PFileSpecification(Environment *ev,
- FW_ODirectorySpecification* directory,
- const FW_CString& fileName)
- {
- FW_OFileSpecification *theFileSpec = new FW_OFileSpecification;
-
- SetRep(ev, theFileSpec);
- theFileSpec->InitFromDirectoryAndName(ev, directory, fileName);
-
- FW_END_CONSTRUCTOR
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_PFileSpecification::FW_PFileSpecification
- //
- // Initialize the specification with fileName. If fileName is a partial pathname, then
- // the current working directory is used.
- //----------------------------------------------------------------------------------------
-
- FW_PFileSpecification::FW_PFileSpecification(Environment *ev, const FW_CString& pathName)
- {
- Clone(ev, pathName);
-
- FW_END_CONSTRUCTOR
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_PFileSpecification::FW_PFileSpecification
- //
- // Acquisition constructor
- //----------------------------------------------------------------------------------------
-
- FW_PFileSpecification::FW_PFileSpecification(Environment *ev, FW_OFileSpecification* specification)
- {
- SetRep(ev, specification);
-
- FW_END_CONSTRUCTOR
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_PFileSpecification::FW_PFileSpecification
- //
- // Copy constructor
- //----------------------------------------------------------------------------------------
-
- FW_PFileSpecification::FW_PFileSpecification(const FW_PFileSpecification& specificationPtr)
- {
- FW_SOMEnvironment ev;
-
- Clone(ev, specificationPtr);
-
- FW_END_CONSTRUCTOR
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_PFileSpecification::~FW_PFileSpecification
- //----------------------------------------------------------------------------------------
-
- FW_PFileSpecification::~FW_PFileSpecification()
- {
- FW_START_DESTRUCTOR
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_PFileSpecification::operator==
- //
- // Equality operator. Compares the location of each file. If the location's match, then
- // the file is a match.
- // Note that the Windows side is case insensitive. On the Mac, FSSMakeFSSpec should
- // normalize file names so conversion should not be necessary.
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_PFileSpecification::operator==(FW_OFileSpecification* theOtherFile) const
- {
- FW_SOMEnvironment ev;
-
- return GetRep()->IsSameAs(ev, theOtherFile);
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_PFileSpecification::operator=
- //
- // Copies info over from pre-verified file specification. Shouldn't need to do any
- // checks.
- //----------------------------------------------------------------------------------------
-
- FW_PFileSpecification& FW_PFileSpecification::operator=(const FW_PFileSpecification& theOtherFile)
- {
- FW_SOMEnvironment ev;
-
- Clone(ev, theOtherFile);
-
- return (*this);
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_PFileSpecification::operator=
- //
- // Set the name of the file. This only changes the name, it doesn't change the previous
- // path. Reverifies the path with the new fileName.
- //----------------------------------------------------------------------------------------
-
- FW_PFileSpecification& FW_PFileSpecification::operator=(const FW_CString& fileName)
- {
-
- FW_SOMEnvironment ev;
-
- Clone(ev, fileName);
-
- return (*this);
- }
-
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // FW_PFileSpecification::FW_PFileSpecification
- //
- // Macintosh FSSpec constructor.
- //----------------------------------------------------------------------------------------
-
- FW_PFileSpecification::FW_PFileSpecification(Environment *ev, const FSSpec& macSpec)
- {
- Clone(ev, macSpec);
-
- FW_END_CONSTRUCTOR
- }
- #endif
-
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // FW_PFileSpecification::operator=
- //----------------------------------------------------------------------------------------
-
- FW_PFileSpecification& FW_PFileSpecification::operator=(const FSSpec& macSpec)
- {
- FW_SOMEnvironment ev;
-
- Clone(ev, macSpec);
-
- return (*this);
- }
- #endif
-
-
- //----------------------------------------------------------------------------------------
- // FW_PFileSpecification::Clone
- //
- // Copy constructor
- //----------------------------------------------------------------------------------------
-
- void FW_PFileSpecification::Clone(Environment *ev, FW_OFileSpecification* specification)
- {
- if (GetRep() == 0)
- SetRep(ev, new FW_OFileSpecification);
-
- GetRep()->AssignOFileSpecification(ev, specification);
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_PFileSpecification::Clone
- //
- // Copy constructor
- //----------------------------------------------------------------------------------------
-
- void FW_PFileSpecification::Clone(Environment *ev, const FW_CString& fileName)
- {
- if (GetRep() == 0)
- SetRep(ev, new FW_OFileSpecification);
-
- GetRep()->InitFromFileName(ev, fileName);
- }
-
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // FW_PFileSpecification::Clone
- //
- // Copy constructor
- //----------------------------------------------------------------------------------------
-
- void FW_PFileSpecification::Clone(Environment *ev, const FSSpec& macSpec)
- {
- if (GetRep() == 0)
- SetRep(ev, new FW_OFileSpecification);
-
- GetRep()->AssignFileSpec(ev, (FSSpec*) &macSpec);
- }
- #endif
-
-
-
- //========================================================================================
- // CLASS FW_PDirectorySpecification
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment FW_PDirectorySpecification
- #endif
-
- FW_DEFINE_AUTO(FW_PDirectorySpecification)
-
- //----------------------------------------------------------------------------------------
- // FW_PDirectorySpecification::FW_PDirectorySpecification
- //
- // Specifies the current working directory.
- //----------------------------------------------------------------------------------------
-
- FW_PDirectorySpecification::FW_PDirectorySpecification()
- {
- FW_SOMEnvironment ev;
- FW_ODirectorySpecification *theFileSpec = new FW_ODirectorySpecification;
-
- SetRep(ev, theFileSpec);
-
- FW_END_CONSTRUCTOR
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_PDirectorySpecification::FW_PDirectorySpecification
- //
- // Copy constructor.
- //----------------------------------------------------------------------------------------
-
- FW_PDirectorySpecification::FW_PDirectorySpecification(Environment *ev, FW_ODirectorySpecification* theFileSpec)
- {
- SetRep(ev, theFileSpec);
-
- FW_END_CONSTRUCTOR
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_PDirectorySpecification::FW_PDirectorySpecification
- //
- // Copy constructor.
- //----------------------------------------------------------------------------------------
-
- FW_PDirectorySpecification::FW_PDirectorySpecification(const FW_PDirectorySpecification& other)
- {
- FW_SOMEnvironment ev;
-
- Clone(ev, other);
-
- FW_END_CONSTRUCTOR
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_PDirectorySpecification::FW_PDirectorySpecification
- //
- // Specifies the path by string. directoryName can be either a full or partial path
- // name.
- //----------------------------------------------------------------------------------------
-
- FW_PDirectorySpecification::FW_PDirectorySpecification(Environment* ev, const FW_CString& directoryName)
- {
- Clone(ev, directoryName);
-
- FW_END_CONSTRUCTOR
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_PDirectorySpecification::~FW_PDirectorySpecification
- //----------------------------------------------------------------------------------------
-
- FW_PDirectorySpecification::~FW_PDirectorySpecification()
- {
- FW_START_DESTRUCTOR
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_PDirectorySpecification::operator==
- //----------------------------------------------------------------------------------------
- FW_Boolean FW_PDirectorySpecification::operator==(FW_ODirectorySpecification* theOtherDir) const
- {
- FW_SOMEnvironment ev;
-
- return GetRep()->IsSameAs(ev, theOtherDir);
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_PDirectorySpecification::operator=
- //----------------------------------------------------------------------------------------
- FW_PDirectorySpecification& FW_PDirectorySpecification::operator=(const FW_PDirectorySpecification& theOtherDir)
- {
- FW_SOMEnvironment ev;
-
- Clone(ev, theOtherDir);
-
- return (*this);
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_PDirectorySpecification::operator=
- //
- // Set the name of the directory to the value specified in directoryName. directoryName
- // should not contain any path delimiters.
- //----------------------------------------------------------------------------------------
- FW_PDirectorySpecification& FW_PDirectorySpecification::operator=(const FW_CString& directoryName)
- {
- FW_SOMEnvironment ev;
-
- Clone(ev, directoryName);
-
- return (*this);
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_PDirectorySpecification::operator+=
- //
- // Adds directoryName on to the end of this directory.
- // In this case, the new name is assigned to the internal FileSpec, where it is interpeted
- // as a partial path.
- //----------------------------------------------------------------------------------------
- FW_PDirectorySpecification& FW_PDirectorySpecification::operator+=(const FW_CString& directoryName)
- {
- FW_SOMEnvironment ev;
-
- GetRep()->AppendDirectoryName(ev, directoryName);
-
- return (*this);
- }
-
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // FW_PDirectorySpecification::FW_PDirectorySpecification
- //----------------------------------------------------------------------------------------
-
- FW_PDirectorySpecification::FW_PDirectorySpecification(Environment* ev, const FSSpec& macSpec)
- {
- Clone(ev, macSpec);
-
- FW_END_CONSTRUCTOR
- }
- #endif
-
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // FW_PDirectorySpecification::operator=
- //
- // Copies the Macintosh FSSpec for this directory into specification.
- //----------------------------------------------------------------------------------------
-
- FW_PDirectorySpecification& FW_PDirectorySpecification::operator=(const FSSpec& macSpec)
- {
- FW_SOMEnvironment ev;
-
- Clone(ev, macSpec);
-
- return (*this);
- }
- #endif
-
-
- //----------------------------------------------------------------------------------------
- // FW_PDirectorySpecification::Clone
- //
- // Copy constructor
- //----------------------------------------------------------------------------------------
-
- void FW_PDirectorySpecification::Clone(Environment *ev, FW_ODirectorySpecification* specification)
- {
- if (GetRep() == 0)
- SetRep(ev, new FW_ODirectorySpecification);
-
- GetRep()->AssignOFileSpecification(ev, specification);
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_PDirectorySpecification::Clone
- //
- // Copy constructor
- //----------------------------------------------------------------------------------------
-
- void FW_PDirectorySpecification::Clone(Environment *ev, const FW_CString& fileName)
- {
- if (GetRep() == 0)
- SetRep(ev, new FW_ODirectorySpecification);
-
- GetRep()->InitFromFileName(ev, fileName);
- }
-
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // FW_PDirectorySpecification::Clone
- //
- // Copy constructor
- //----------------------------------------------------------------------------------------
-
- void FW_PDirectorySpecification::Clone(Environment *ev, const FSSpec& macSpec)
- {
- if (GetRep() == 0)
- SetRep(ev, new FW_ODirectorySpecification);
-
- GetRep()->AssignFileSpec(ev, (FSSpec*) &macSpec);
- }
- #endif
-